list1 = [1,2,3,4,5]
for i in range(len(list1)):
    print(list1[i],end=' ')
print()
print('-------------')
for i in list1:
    print(i,end=' ')
print()
print('-------------')

# 追加元素
list1.append(6)
print(list1)
list2 = [7,8,9]
list1.extend(list2)
print(list1)
print(list2)
list1.insert(2,66)
print(list1)
# 排序
list1.sort() # 正序排序
print(list1)

list1.reverse()# 反转
print(list1)

list1.sort(reverse=True)# 降序排序
print(list1)

list3 = [14,22,3,4,5]# 返回新的列表是升序 原列表不变
list4 = sorted(list3)
print(list3)
print(list4)
# 删除元素
num = list4.pop() # 返回删除的元素
print(num)
print(list4)

set1 = {1,2,3,4,5} # 无序 无法通过下标查找  在使用pop时是随机删除某个元素
for i in set1:
    print(i,end=' ')

dict1 = {'name':'zhangsan','age':18}
dict1['sex'] = 'male' # 增加add
dict1['age'] = 19  # 修改update
for key in dict1:
    print(key,end=' ')
for key,value in dict1.items():
    print(key,value)
print(dict1.keys())